package com.jiangcheng.demo.controller;


import com.jiangcheng.demo.service.CommentService;
import com.jiangcheng.demo.utils.NewResult;
import io.swagger.annotations.Api;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.jiangcheng.demo.entity.Comment;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author admin
 * @since 2021-07-26
 */
@Api("评论相关API")
@RestController
@RequestMapping("/comment")
public class CommentController {
    @Autowired
    CommentService commentService;

    // 获取评论
    @GetMapping("/comments/{art_id}/{u_id}")
    public NewResult findComments(@PathVariable("art_id") int artId,@PathVariable("u_id") int uId){
        return commentService.findCommentsByArtId(artId,uId);
    }
    // 添加评论
    @PostMapping("/addComment")
    public NewResult insertComment(Comment comment){
        return commentService.insertComment(comment);
    }
}

